package com.aigeth.batisbase;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface BaseMapper<T> {
    //新增一条数据
    @InsertProvider(method = "add", type = BaseSqlProvider.class)
    @Options(useGeneratedKeys = true)
    public int add(T bean);

    //根据主键删除一条数据
    @DeleteProvider(method = "delete", type = BaseSqlProvider.class)
    public int delete(T bean);

    @DeleteProvider(method = "deleteWhere", type = BaseSqlProvider.class)
    public int deleteWhere(T bean, String... where);

    @DeleteProvider(method = "deleteWhere2", type = BaseSqlProvider.class)
    public int deleteWhere2(T bean, String... where);

    //根据主键获取一条数据
    @SelectProvider(method = "get", type = BaseSqlProvider.class)
    public T get(T bean, String... where);

    @SelectProvider(method = "findColsByWhere", type = BaseSqlProvider.class)
    public List<Object> findColsByWhere(String cols, String... where);

    //修改一条数据
    @UpdateProvider(method = "update", type = BaseSqlProvider.class)
    public int update(T bean);

    @UpdateProvider(method = "updateWhere", type = BaseSqlProvider.class)
    public int updateWhere(T bean, String... where);
    @UpdateProvider(method = "updateWhere2", type = BaseSqlProvider.class)
    public int updateWhere2(T bean, String where);

    @SelectProvider(method = "findList", type = BaseSqlProvider.class)
    public List<T> findList(T bean);

    /**
     * 分页查询
     *
     * @param bean    实体类
     * @param orderby 排序
     * @return
     */
    @SelectProvider(method = "findListPage", type = BaseSqlProvider.class)
    public List<T> findListPage(T bean, String orderby);

    @SelectProvider(method = "findCount", type = BaseSqlProvider.class)
    public Integer findCount(T bean);
}
